I envision this figure much like the previous one, in a 1-column vertical distribution of panels. At top, you would show the data spectrum at an overlap of two spectral orders, along with the post-processed model with no Chebyshev polynomials applied. Next, you would show the two Chebyshev polynomials appropriate for the two orders. And then in the final panel you would revisit the top panel with the polynomials applied, demonstrating the improvement.


In [1]:
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter as FSF
from matplotlib.ticker import MultipleLocator
from matplotlib.ticker import MaxNLocator
import numpy as np

from StellarSpectra.spectrum import DataSpectrum

In [2]:
myDataSpectrum = DataSpectrum.open("../../data/WASP14/WASP14-2009-06-14.hdf5", orders=[22,23])
wls = myDataSpectrum.wls
fls = myDataSpectrum.fls

In [3]:
plt.plot(wls[0], fls[0])
plt.plot(wls[1], fls[1])
plt.show()

In [3]:
from StellarSpectra.model import Model
from StellarSpectra.spectrum import DataSpectrum
from StellarSpectra.grid_tools import TRES, HDF5Interface


myInstrument = TRES()
myHDF5Interface = HDF5Interface("../../libraries/PHOENIX_TRES_F.hdf5")

myModel = Model.from_json("WASP14_model_final.json", myDataSpectrum, myInstrument, myHDF5Interface)


Determine Chunk Log: Wl is 16384
Creating OrderModel 0
Creating OrderModel 1

In [4]:
model22 = myModel.OrderModels[0]
model23 = myModel.OrderModels[1]

cheb22 = model22.get_Cheb()
cheb23 = model23.get_Cheb()

fl22 = model22.get_spectrum()
fl23 = model23.get_spectrum()

fl22n = fl22/cheb22
fl23n = fl23/cheb23

Get a model spectrum with cheb set to 0.0, or just divide by the cheb spectrum


In [16]:
import matplotlib
matplotlib.rc("lines", linewidth=0.75)

fig, ax = plt.subplots(nrows=4, figsize=(3.5, 6), sharex=True)

#ax[0].plot(wls[0], fl22n, "r", lw=0.5)
#ax[0].plot(wls[1], fl23n, "r", lw=0.5)

ax[0].plot(wls[0], fls[0], "g", label="order 23")
ax[0].plot(wls[1], fls[1], "m", label="order 24")
ax[0].legend(loc="lower right", ncol=2, prop={'size':10})
ax[0].set_ylabel(r"$f_\lambda \quad [\textrm{erg}\;\textrm{cm}^{-2}\;\textrm{s}^{-1}\;\textrm{\AA}^{-1}]$", labelpad=9)

ax[1].plot(wls[0], cheb22, "g")
ax[1].plot(wls[1], cheb23, "m")
ax[1].yaxis.set_major_formatter(FSF("%.2f"))

ax[2].plot(wls[0], fls[0]/cheb22, "g")
ax[2].plot(wls[1], fls[1]/cheb23, "m")

ax[3].plot(wls[0], fl22, "g")
ax[3].plot(wls[1], fl23, "m")

for i,a in enumerate(ax):
    if i != 1:
        a.set_ylim(5e-14, 2.38e-13)

labels = ["raw", "Chebyshev", "corrected data", "distorted model"]

for a, label in zip(ax, labels):
    a.annotate(label, (0.05, 0.85), xycoords="axes fraction")
    a.yaxis.set_major_locator(MaxNLocator(nbins=6, prune='both'))

fig.text(0.06, 0.4, r"$f_\lambda \quad [\textrm{erg}\;\textrm{cm}^{-2}\;\textrm{s}^{-1}\;\textrm{\AA}^{-1}]$", rotation="vertical")

ax[-1].set_xlim(5229, 5236)
ax[-1].xaxis.set_major_formatter(FSF("%.0f"))
ax[-1].xaxis.set_major_locator(MultipleLocator(2.))
ax[-1].set_xlabel(r"$\lambda$  [\AA]")

fig.subplots_adjust(left=0.2, top=0.94, hspace=0)
fig.savefig("../../plots/chebyshev.png")
fig.savefig("../../plots/chebyshev.pdf")
fig.savefig("../../plots/chebyshev.svg")

plt.show()

In [ ]: